/*
 * shape.c
 *
 *  Created on: Jul 4, 2008
 *      Author: Carlos Oliveira
 */
#include <stdlib.h>
#include <stdio.h>
#include "shape.h"


static void standardDraw(Shape *shape)
{
}

static void standardDelete(void *shape)
{
	printf("delete shape\n");
	free(shape);
}

static int standardNumDefiningPoints()
{
	return 1;
}

static ShapeVTable shapeVTable = {
		standardDraw,
		standardDelete,
		standardNumDefiningPoints
};


Shape *shape_new(GContext context)
{
	Shape *s = (Shape*)malloc(sizeof(Shape));
	if (!s) return 0;
	s->vtable = &shapeVTable;
	s->context = context;
	return s;
}

void shape_delete(Shape *shape)
{
	shape->vtable->deleteFunc(shape);
}

void shape_draw(Shape *shape)
{
	shape->vtable->drawFunc(shape);
}

int shape_numDefiningPoints(Shape *shape)
{
	return shape->vtable->numPointsFunc();
}

GContext shape_getContext(Shape *shape)
{
	return shape->context;
}
